import requests
import sys


class CannotGetLine(Exception):
    def __init__(self, url: str):
        super(CannotGetLine, self).__init__()
        self.mess = 'Can not access ' + url

    def __str__(self):
        return self.mess


def get_nama_html(target_site: str) -> bytes:
    try:
        nama_html = requests.get(target_site)
    except Exception:

        raise CannotGetLine(target_site)

    return nama_html.content


def html_handle(target_site: str, return2bs4: bytes) -> bytes:
    return2bs4temp = return2bs4
    try:
        return2bs4temp = get_nama_html(target_site)
    except Exception:
        return html_handle(target_site, return2bs4temp)
    return return2bs4temp


if __name__ == '__main__':
    ## check if the web is access
    # try:
    #     target_mana_site=sys.argv[1]
    # except IndexError as ie:
    #     print('no web site')

    target_mana_site = 'https://store.line.me/stickershop/product/14308849'
    # nama_html=requests.get(target_mana_site)
    # print(nama_html.content)
    nama_target_html = b''
    nama_target_html = html_handle(target_mana_site, nama_target_html)
    # try:
    #     nama_target_html=get_nama_html(target_mana_site)
    # except CannotGetLine as cg:
    #     print(cg)

    print(nama_target_html)
